package com.qzsoft.system.modules.permission.group.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import com.qzsoft.system.modules.permission.group.dto.SysGroupRoleDTO;
import com.qzsoft.system.modules.permission.group.entity.SysGroupEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 权限角色分组表(权限角色)(SysRoleGroup)表数据库访问层
 *
 * @author zt
 * @since 2020-09-22 14:24:44
 */
@Mapper
@Repository
public interface SysGroupDao extends BaseMapper<SysGroupEntity> {

    @Select("select sr.name as roleName ,sr.type,sr.id as roleId from sys_role_group  srg inner join sys_role sr on sr.id=srg.role_id and srg.group_id =#{id} ")
    List<SysGroupRoleDTO> selectDefaultList(String id);

    @Select("SELECT\n" +
            "\tmax( order_id ) orderId \n" +
            "FROM\n" +
            "\tsys_group \n" +
            "WHERE\n" +
            "\thas_delete = 0 \n" +
            "\tAND pid = #{pid}")
    Integer selectMaxOrderId(String pid);
}